import React from 'react';
import Styles from './../index.less';
import StationHistoryData from './table/AllData';
import BatteryBoxDetails from './table/BatteryBoxDetails'; // 导入新的组件
import BatteryBoxSummary from './table/BatteryBoxSummary'; // 导入新的组件
import BatteryClusterInfo from './table/BatteryClusterInfo'; // 导入新的组件
import BatteryModuleInfo from './table/BatteryModuleInfo'; // 导入新的组件
import BatteryStackInfo from './table/BatteryStackInfo'; // 导入新的组件
import ChargingPileDetails from './table/ChargingPileDetails'; // 导入新的组件
import ChargingPileSummary from './table/ChargingPileSummary'; // 导入新的组件
import IntegratedCabinetDetails from './table/IntegratedCabinetDetails'; // 导入新的组件
import IntegratedCabinetSummary from './table/IntegratedCabinetSummary'; // 导入新的组件
import InverterDetails from './table/InverterDetails'; // 导入新的组件
import InverterSummary from './table/InverterSummary'; // 导入新的组件
import LcDetails from './table/LcDetails';
import MeterDetails from './table/MeterDetails';
import MeterSummary from './table/MeterSummary';
import PartitionHistoryData from './table/PartitionHistoryData';
import PCSControllerDetails from './table/PCSControllerDetails'; // 导入新的组件
import PCSControllerSummary from './table/PCSControllerSummary'; // 导入新的组件
import PCSDetails from './table/PCSDetails'; // 导入新的组件
import PCSSummary from './table/PCSSummary'; // 导入新的组件
import StationAllData from './table/StationAllData';
import TransformerDetails from './table/TransformerDetails'; // 导入新的组件
import TransformerSummary from './table/TransformerSummary'; // 导入新的组件

interface Props {
  areaId?: string;
  deviceCode?: string;
  deviceType?: string;
  nodeType?: string;
  isArea?: boolean;
  selectedKeys?: string[];
}

const HistoryData: React.FC<Props> = ({
  areaId,
  deviceCode,
  deviceType,
  nodeType,
  isArea,
  selectedKeys,
}) => {
  const renderTableComponent = () => {
    if (deviceType === 'STATION' && isArea === true) {
      return (
        <StationHistoryData
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'STATION' && isArea === false) {
      return (
        <StationAllData
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (nodeType === 'AREA') {
      return (
        <PartitionHistoryData
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }

    if (deviceType === 'CHARGE_PILE' && nodeType === 'DEVICE_GROUP') {
      return (
        <ChargingPileSummary
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'CHARGE_PILE' && nodeType === 'DEVICE') {
      return (
        <ChargingPileDetails
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'METER' && nodeType === 'DEVICE_GROUP') {
      return (
        <MeterSummary
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'METER' && nodeType === 'DEVICE') {
      return (
        <MeterDetails
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (
      (deviceType === 'BOX' && nodeType === 'DEVICE_GROUP') ||
      (deviceType === 'CABINET' && nodeType === 'DEVICE_GROUP')
    ) {
      return (
        <BatteryBoxSummary
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (
      (deviceType === 'BOX' && nodeType === 'DEVICE') ||
      (deviceType === 'CABINET' && nodeType === 'DEVICE')
    ) {
      return (
        <BatteryBoxDetails
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    // 电池堆
    if (deviceType === 'BMS' && nodeType === 'DEVICE') {
      return (
        <BatteryStackInfo
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    // 电池簇
    if (deviceType === 'CLUSTER' && nodeType === 'DEVICE') {
      return (
        <BatteryClusterInfo
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    // 电池模组
    if (deviceType === 'BMU' && nodeType === 'DEVICE') {
      return (
        <BatteryModuleInfo
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'PCS_CONT' && nodeType === 'DEVICE_GROUP') {
      return (
        <PCSControllerSummary
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'PCS_CONT' && nodeType === 'DEVICE') {
      return (
        <PCSControllerDetails
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'PCS' && nodeType === 'DEVICE_GROUP') {
      return (
        <PCSSummary
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'PCS' && nodeType === 'DEVICE') {
      return (
        <PCSDetails
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'GLC' && nodeType === 'DEVICE_GROUP') {
      return (
        <IntegratedCabinetSummary
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'GLC' && nodeType === 'DEVICE') {
      return (
        <IntegratedCabinetDetails
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (
      (deviceType === 'LC' && nodeType === 'DEVICE') ||
      (deviceType === 'LC' && nodeType === 'DEVICE_GROUP')
    ) {
      return (
        <LcDetails
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'INVERTER' && nodeType === 'DEVICE_GROUP') {
      return (
        <InverterSummary
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'INVERTER' && nodeType === 'DEVICE') {
      return (
        <InverterDetails
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'TRANSFORMER' && nodeType === 'DEVICE_GROUP') {
      return (
        <TransformerSummary
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
    if (deviceType === 'TRANSFORMER' && nodeType === 'DEVICE') {
      return (
        <TransformerDetails
          deviceCode={deviceCode}
          deviceType={deviceType}
          areaId={areaId}
          selectedKeys={selectedKeys}
        />
      );
    }
  };

  return <div className={Styles.historyTable}>{renderTableComponent()}</div>;
};

export default HistoryData;
